home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / sbprolog / amiga / v3_1 / sbp3_1e.lzh / AMPERS.PL < prev    next >
Text File  |  1991-10-31  |  847b  |  30 lines

  1. /* From the book PROLOG PROGRAMMING IN DEPTH
  2.    by Michael A. Covington, Donald Nute, and Andre Vellino.
  3.    Copyright 1988 Scott, Foresman & Co.
  4.    Non-commercial distribution of this file is permitted. */
  5. /* Modified for Quintus Prolog by Andreas Siebert */
  6.  
  7. /* AMPERS.PL */
  8.  
  9. /* Defines the ampersand (&) as a compound goal constructor,
  10.    to avoid the ambiguity created by using commas */
  11.  
  12. :- op(950,xfy,&).                       /* syntax of & */
  13.  
  14. GoalA & GoalB  :-  call(GoalA),
  15.                    call(GoalB).         /* semantics of & */
  16.  
  17.  
  18. /* Knowledge base to demonstrate the ampersand */
  19.  
  20. parent(michael,cathy).
  21. parent(melody,cathy).
  22. parent(charles_gordon,michael).
  23. parent(hazel,michael).
  24. parent(jim,melody).
  25. parent(eleanor,melody).
  26.  
  27. grandparent(X,Y) :- parent(Z,Y) & parent(X,Z).
  28.  
  29. only_child(X) :- parent(P,X) & \+ (parent(P,Z) & Z\==X).
  30.